home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / sound / aiff writer sdev / structures.h < prev   
Encoding:
C/C++ Source or Header  |  2000-09-28  |  4.6 KB  |  122 lines

  1. /*
  2.     File:        Structures.h
  3.  
  4.     Contains:    Header for routines which deal with virtual sound hardware from a
  5.                 'sdev' component.
  6.  
  7.     Written by: Mark Cookson    
  8.  
  9.     Copyright:    Copyright © 1993-1999 by Apple Computer, Inc., All Rights Reserved.
  10.  
  11.                 You may incorporate this Apple sample source code into your program(s) without
  12.                 restriction. This Apple sample source code has been provided "AS IS" and the
  13.                 responsibility for its operation is yours. You are not permitted to redistribute
  14.                 this Apple sample source code as "Apple sample source code" after having made
  15.                 changes. If you're going to re-distribute the source, we require that you make
  16.                 it clear in the source that the code was descended from Apple sample source
  17.                 code, but that you've made changes.
  18.  
  19.     Change History (most recent first):
  20.                 8/16/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  21.                 
  22.  
  23. */
  24.  
  25. #ifndef __STRUCTURES__
  26. #define __STRUCTURES__
  27.  
  28. #include <Files.h>
  29. #include <SoundComponents.h>
  30. #include <Timer.h>
  31. #include <Types.h>
  32.  
  33. #ifndef __AIFFWRITER__
  34. #include "AIFF_writer.h"
  35. #endif
  36.  
  37. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  38. // Constants
  39. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  40.  
  41. #define kSoundComponentVersion    0x10000                    /* version for this component */
  42. #define kSndFileName            "\pSound 1"                /* name for sound file data is written to */
  43. #define fsNoCache                32                        /* set this bit to not use the cache in a PBWrite */
  44.  
  45. #define kSecondsInIOBuffer        1                        /* no. seconds of audio data in each I/O buffer */
  46. #define kHardwareBufferSize        512                        /* size of hardware buffer */
  47. #define kDelegateSifterCall    ((ComponentRoutine) -1L)    /* flag that selector should be delegated instead of called */
  48.  
  49. #ifndef kFix1
  50. #define kFix1                ((Fixed)(0x00010000))        /* 1.0 in fixed point */
  51. #endif
  52.  
  53. #define kComponentWantsToRegister 0            /* component wants to be registered */
  54. #define kComponentDoesNotWantToRegister    1    /* component doesn't want to be registered */
  55.  
  56. #define SoundComponentEntryPoint        HackBlaster        //Our entry point instead of __start
  57.  
  58. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  59. // Structures
  60. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  61.  
  62. /* Data structure passed to some GetInfo calls */
  63.  
  64. typedef struct {
  65.     short    count;
  66.     Handle    handle;
  67. } HandleList, *HandleListPtr;
  68.  
  69. /* My time manager task record includes space for my globals at the end */
  70.  
  71. typedef struct SoundComponentGlobals SoundComponentGlobals;
  72. typedef SoundComponentGlobals *SoundComponentGlobalsPtr;
  73. typedef SoundComponentGlobalsPtr *SoundComponentGlobalsHandle;
  74.  
  75. typedef struct {
  76.     TMTask                        task;
  77.     SoundComponentGlobalsPtr    globals;
  78. } myTMTask, *myTMTaskPtr;
  79.  
  80. /* i/o buffer structure */
  81.  
  82. typedef struct {
  83.     ParamBlockRec    iopb;                            // i/o parameter block
  84.     long            byteCount;                        // no. bytes in buffer
  85.     Ptr                buffer;                            // buffer for data
  86.     Handle            bufferHandle;                    // handle to buffer
  87. } IOBuffer, *IOBufferPtr;
  88.  
  89. /* Component globals */
  90.  
  91. struct SoundComponentGlobals {
  92.  
  93. // these are general purpose variables that every component will need
  94.     ComponentInstance        sourceComponent;            // component to call when hardware needs more data
  95.     SoundComponentDataPtr    sourceDataPtr;                // pointer to source data structure
  96.     SoundComponentData        thisSifter;                    // description of data this component outputs
  97.     Handle                    globalsHandle;                // handle to component globals
  98.     Boolean                    inSystemHeap;                // true if component loaded in system heap, false if in app heap
  99.     Boolean                    hardwareOn;                    // true if hardware is on, false if it is off
  100.  
  101. // these are variables specific to this component implementation
  102.     HardwareGlobalsPtr        hwGlobals;                    // pointer to hardware globals
  103.     unsigned long            nextTime;                    // next time to interrupt
  104.     unsigned long            ioBufferSize;                // size of i/o buffer in bytes
  105.     long                    interruptInterval;            // time in microseconds between interrupts
  106.     myTMTask                tmTask;                        // time manager task record used to trigger interrupt
  107.     long                    headerLen;                    // length of AIFF header written to beginning of file
  108.     short                    fRefNum;                    // fref of file to save data into
  109.     short                    currentIndex;                // current buffer to save data into
  110.     IOBuffer                ioBuffers[2];                // buffer descriptions
  111. };
  112.  
  113. /*    It is possible to debug this component using Think C. To do this, you cannot call the time
  114.     manager to generate interrupts, since Think C is not re-entrant. This means you must call
  115.     the FakeInterrupt routine described below during main event loop time, and define the
  116.     FakeInterrupts variable. */
  117.  
  118. #ifdef FakeInterrupts
  119. SoundComponentGlobalsPtr        gGlobals;
  120. #endif
  121.  
  122. #endif //#ifndef __STRUCTURES__